# -*- coding: utf-8 -*-
"""
    @Author ljy
    @Date 2020/11/5 9:36
    @Describe 
"""
from typing import Optional
from pydantic import BaseModel,Field


# 定制修改（更新用户）信息字段
class UserInfo(BaseModel):  # 定制请求体body的模型类，期待的json对象的属性
    nick_name:Optional[str] = Field(None,max_length=20,regex=r'[\u4e00-\u9fa5]+',title='中文的昵称')
    phone:Optional[str] = Field(None,regex=r'^1[3-9]\d{9}$',title='手机号')
    email:Optional[str] = Field(None,regex=r'^\w+?@.+.\.(com|cn|net|org|edu)$',title='邮箱')


# 定制注册用户字段
class RegistUser(UserInfo):
    # 请求体的模型类是可以继承的
    username:Optional[str] = Field(...,regex=r'^[a-zA-Z]\w{5,}$')
    password:Optional[str] = Field(...,min_length=8,title='口令')
    password2:Optional[str] = Field(...,min_length=8,title='确认口令')


# 定制找回密码用户字段
class FindPwd(UserInfo):
    username:Optional[str] = Field(...)
    password:Optional[str] = Field(...)


class PwdSecure(BaseModel):
    title:Optional[str] = Field(...,max_length=20,title='问题描述')
    result:Optional[str] = Field(...,max_length=20,title='问题答案')









